﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DemoApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            SQLServerDemo sqlServerDemo = new SQLServerDemo();
            UserInfo userInfo = new UserInfo
            {
                Age=40,
                Email="www@ww.com",
                Mobile="17712345678",
                Phone="021-56789012",
                RealName="关公",
                Sex=true,
                UserName="guangong"
            };

            bool success=sqlServerDemo.AddUsers(userInfo);
            if (success)
            {
                Console.WriteLine("添加用户成功！");
            }
            success = sqlServerDemo.DeleteUser(10);
            if (success)
            {
                Console.WriteLine("删除用户成功！");
            }
            System.Data.DataTable data=sqlServerDemo.GetUsers(5);
            if (data.Rows.Count > 0)
            {
                Console.WriteLine("查询用户成功！");
            }
            List<UserInfo> userList=sqlServerDemo.GetUserList(data);
            if (userList.Count > 0)
            {
                Console.WriteLine("将DataTable中的数据转换成UserInfo实例成功！");
                userInfo = userList[0];
                userInfo.Age = 56;
                userInfo.Email = "zhouwqq@163.com";
                success = sqlServerDemo.UpdateUser(userInfo);
                if (success)
                {
                    Console.WriteLine("更新用户成功！");
                }
            }
        }
    }
}
